<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //join()把数组中元素"以什么"相连成字符串
    // var arr1 = [1, 2, 3];
    var arr1 = ['1', '2', '3'];//与上面相等
    console.log(arr1.join()); // 1,2,3
    console.log(arr1.join(","));//1,2,3    
    console.log(arr1.join(" ")); //1 2 3
    console.log(arr1.join("-")); //1-2-3
    console.log([""].join());//[""][''][] 空


    //split("") "以什么"做分割 把字符串转数组
    var str="How are you?"
    
    console.log(str.split(" "));//["How", "are", "you?"]
    console.log(str.split(","));//["How are you?"]
    console.log(str.split(""));//["H", "o", "w", " ", "a", "r", "e", " ", "y", "o", "u", "?"]
    console.log(str.split(" ",3));//["How", "are", "you?"]
    
    console.log("2:3:4:5".split(":"));//["2", "3", "4", "5"]
    console.log("'2','3','4'".split(','));// ["'2'", "'3'", "'4'"]
    console.log("2,3,4".split(','));//["2", "3", "4"]

    console.log("".split(','));//[""]
    console.log(''.split(','));//[""]

    //concat
    var arr3 = [1, 3, 5, 7];
    var arrCopy = arr1.concat(9,[1,2]);
    console.log(arrCopy); //["1", "2", "3", 9, 1, 2]
    console.log(arr3);//[1, 3, 5, 7]

   
  </script>
</body>

</html>